<?php

namespace app\site\controller;

use app\common\model\ActionLogModel;
use think\Request;

class ActionLogController extends BaseController
{
    private $actionLog;
    /**
     * 初始化
     * AreaController constructor.
     * @param Request $request
     */
    public function __construct(Request $request)
    {
        parent::__construct($request);
        $this->actionLog = new ActionLogModel();
    }

    public function index(){
        $map['site_id'] = $this->getSiteId();
        $map['module'] = $this->getUtype();
        $btime = $this->request->param('btime');
        if(!empty($btime)){
            $query['btime'] = $btime;
            $sbtime = strtotime($btime);
        }else{
            $sbtime = strtotime(0);
        }
        $etime = $this->request->param('etime');
        $query['etime'] = $etime;
        $setime = empty($etime)?time():strtotime($etime." 23:59:59");
        $map['create_time'] = ['between',[$sbtime,$setime]];
        $list = $this->actionLog->where($map)->order('id desc')->paginate(20,false,['query'=>$query]);
        $this->assign('list',$list);
        $this->assign('query',$query);
        return $this->fetch();
    }
}